Repository navigation
Delete src/lib (ITensorsExtensions + BaseExtensions submodules) - #364
Merged
Merged
Conversation
Cross-codebase usage audit found ~110 of the submodule's 258 lines
uncalled. Three groupings of changes:
**Dead-code deletions:**
- `sqrt_diag` / `inv_diag` / `invsqrt_diag` / `pinv_diag` / `pinvsqrt_diag`
(five convenience wrappers around `map_diag`, zero callers).
- `diagblocks` (both `Tensor` and `ITensor` methods, zero callers) along
with its supporting `DenseTensor` overloads of `NDTensors.blockoffsets`
/ `nzblocks` / `blockdim` (only consumer was the now-dead `diagblocks`).
- `LinearAlgebra.isdiag(::ITensor)` (zero callers; `apply.jl` and the
internal `map_eigvals` reference resolve to `ITensors.isdiag`).
- `is_delta` (three methods, zero callers).
- `ITensors._contract(::Key)` dispatch patch (bypassed because
`contract.jl:18` unwraps `Key`-wrapped sequences via `deepmap` before
reaching `_contract`).
- `ITensors.replaceinds(::ITensor, ::Dict{<:Index, <:Index})` performance
patch (zero callers in src/, test/, or ext/).
**Type-system block transitively dead — entry chain `trivial_space(x)`
→ `promote_indtypeof(x)` had only test callers:**
- `make_bosonic` and the `using_auto_fermion` / `has_fermionic_subspaces`
fermion branch in `map_eigvals`. The corresponding "Fermionic map
eigvals tests" testset in `test_itensorsextensions.jl` is dropped.
The fermion-agnostic "Fermionic eigendecomp" testset (which tests
`eigendecomp` directly) stays.
- `promote_indtypeof(::AbstractITensorNetwork)`, `promote_indtypeof
(::AbstractIndsNetwork)`, and the `function promote_indtypeof end`
declaration.
- `indtype(::ITensor)`, `indtype(::IndsNetwork)`, and `indtype(::Type{
<:IndsNetwork{V, I}})`. The user-facing `indtype(link_space,
site_space)` 4-form (used by the `IndsNetwork{V,I}` constructor to
infer `I`) stays.
- `promote_indtype(::Vararg{Type{<:Index}})`, `promote_indtype_rule`,
`promote_spacetype_rule` (four methods), `spacetype` — all only
reached through the deleted `promote_indtypeof` chain.
- `trivial_space` (all four methods) — replaced at its single test
callsite by an inline `hasqns`-conditional helper in `test/utils.jl`.
**Test-only relocations:**
- `replace_vertices` and its internal `set_sites` helper, used only by
`test/test_opsum_to_ttn_mpo_cross_check.jl`, move to `test/utils.jl`.
- `group_terms`, used only by `test/test_tebd.jl`, moves to
`test/utils.jl`.
- `src/lib/ITensorsExtensions/src/opsum.jl` is deleted outright.
**Doc cleanup:**
- Drop the `promote_indtypeof(is::AbstractIndsNetwork)` and `indtype
(inds_network::IndsNetwork)` entries in `docs/src/experimental_methods
.md`.
Final state: the submodule keeps `tensor_sum`, `eigendecomp` +
`map_eigvals` (now fermion-free), and the focused type-system chain
supporting the `IndsNetwork{V,I}` constructor — `IsIndexSpace`,
`indtype(link_space, site_space)` family, `indtype(space)`, `_indtype`.
About 60 LOC instead of 258.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #364 +/- ##
==========================================
+ Coverage 74.96% 76.08% +1.12%
==========================================
Files 63 57 -6
Lines 2820 2710 -110
==========================================
- Hits 2114 2062 -52
+ Misses 706 648 -58
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
After this collapse, src/lib/ goes away entirely. Each helper now lives
in the single src/ or test/ file that uses it:
- `eigendecomp` and `map_eigvals` move from `lib/ITensorsExtensions/`
into `src/apply.jl` (only consumer in `src/` was `simple_update_bp`).
Both are now module-level `ITensorNetworks` functions; `src/apply.jl`
drops the `ITensorsExtensions.` qualifier on its four call sites.
- `tensor_sum` moves from `lib/ITensorsExtensions/` into `src/opsum.jl`
(only consumer was `ITensors.ITensor(::Sum, ::IndsNetwork)` in the
same file).
- The `indtype(link_space, site_space)` 4-form, `indtype(space)`,
`_indtype` family, and `IsIndexSpace` move from
`lib/ITensorsExtensions/` into `src/indsnetwork.jl` (only consumer
was the `IndsNetwork{V, I}(g, link_space, site_space)` constructor).
- `maybe_real` moves from `lib/BaseExtensions/` into `src/opsum.jl`
(consumers were `src/opsum.jl` and `src/apply.jl`; both files reach
it as a top-level `ITensorNetworks` function now). `to_tuple` was
only used in `test/utils.jl::group_terms` and moves there directly.
- `test/test_itensorsextensions.jl` renamed to `test/test_map_eigvals.jl`,
imports updated from `ITensorNetworks.ITensorsExtensions: ...` to
`ITensorNetworks: ...`. The testset name changes from
`"ITensorsExtensions"` to `"map_eigvals"`.
- `include("lib/BaseExtensions/...")` removed from
`src/ITensorNetworks.jl`; `src/lib/` directory deleted outright.
Net effect: drops two submodules' worth of indirection without losing
any in-tree behavior. All tests pass.
These three methods in `src/apply.jl` had no callers anywhere — TEBD
calls `apply(::Vector{ITensor}, ψ)` after materializing the Trotter
product into ITensors via `Vector{ITensor}(::Prod, ::IndsNetwork)`,
not `apply(::Op|::Prod|::Scaled, ψ)`. The rest of the OpSum→ITensor
chain in `src/opsum.jl` (including `tensor_sum` and `maybe_real`) is
still alive through that materialization step and stays.
Three follow-up cleanups beyond the `src/lib/` collapse:
- Remove 8 `Project.toml` deps that have zero references anywhere in
`src/`, `ext/`, or `docs/`: `AbstractTrees`, `Combinatorics`, `Compat`,
`ConstructionBase`, `IterTools`, `SerializedElementArrays`,
`Suppressor`, `TimerOutputs`. Tests aren't using them either —
`Compat`'s test usage stays in `test/Project.toml`.
- Delete `src/partitioneditensornetwork.jl` (10-line file whose sole
contents were a `linkinds(::PartitionedGraph, ::QuotientEdge)` wrapper
used only by `linkinds(::AbstractBeliefPropagationCache,
::QuotientEdge)`). Inline the 3-line body into the BPC method.
- Narrow `apply(::Union{NamedEdge, ITensor}, ::AbstractITensorNetwork)`,
`apply(::Union{Vector{NamedEdge}, Vector{ITensor}}, ::TN)`, and the
internal `simple_update_bp(::Union{NamedEdge, ITensor}, ...)` to just
`::ITensor` / `::Vector{ITensor}`. No callers anywhere exercised the
`NamedEdge` arm.
Doc updates:
- Drop the `partitioneditensornetwork.jl` entry from
`docs/src/deprecated_methods.md`.
- Narrow the `apply` signature listing in `docs/src/interface_methods.md`
to match.
Zero references in test/*.jl; was carried over alongside the same dep in the main Project.toml.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cleanup pass over
src/lib/and related dead code. Every helper that survived an audit now lives in the singlesrc/ortest/file that uses it; everything else was dead, test-only, or architecturally misplaced.src/lib/ITensorsExtensions/andsrc/lib/BaseExtensions/— both submodules deleted. Live helpers moved to their consumers:eigendecomp/map_eigvals→src/apply.jl,tensor_sum/maybe_real→src/opsum.jl, theindtype(link_space, site_space)chain →src/indsnetwork.jl,to_tuple→test/utils.jl. Test-only helpers (replace_vertices,group_terms) moved totest/utils.jl. Dead code removed: the*_diagwrappers,diagblocks,LinearAlgebra.isdiag(::ITensor),is_delta, the_contract(::Key)andreplaceinds(::Dict)patches, and the entirepromote_indtypeof/trivial_space/promote_indtypechain whose only callers were test-internal.map_eigvalsfermion branch —make_bosonicand theusing_auto_fermion()wrapper are gone. Corresponding"Fermionic map eigvals tests"testset dropped along with the capability.apply(::Op|::Prod|::Scaled, ::AbstractITensorNetwork)— three dead methods insrc/apply.jl. TEBD callsapply(::Vector{ITensor}, ψ)after materializing the operator tree viaVector{ITensor}(::Prod, ::IndsNetwork).applyNamedEdge arm —apply(::Union{NamedEdge, ITensor}, ::TN),apply(::Union{Vector{NamedEdge}, Vector{ITensor}}, ::TN), andsimple_update_bp(::Union{NamedEdge, ITensor}, ...)narrowed to just::ITensor/::Vector{ITensor}. No callers exercised theNamedEdgearm.src/partitioneditensornetwork.jl— deleted. Sole content was alinkinds(::PartitionedGraph, ::QuotientEdge)wrapper used only by the BPClinkindsmethod; inlined intosrc/caches/abstractbeliefpropagationcache.jl.Project.toml— 8 unused dependencies removed (AbstractTrees,Combinatorics,Compat,ConstructionBase,IterTools,SerializedElementArrays,Suppressor,TimerOutputs). Tests aren't using them either.test/test_itensorsextensions.jl→test/test_map_eigvals.jl.docs/src/experimental_methods.md,docs/src/interface_methods.md,docs/src/deprecated_methods.md.Targeting the
0.22.0-DEVaccumulator.🤖 Generated with Claude Code